import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Note from "@/views/Note.vue";
import FamilyView from "@/views/FamilyView.vue";
import AvatarView from "@/views/AvatarView.vue";
import UserView from "@/views/UserView.vue";

Vue.use(VueRouter)

//定义路由
const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about/:id', //:id 就会匹配路径中的数据
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: function () {
      return import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    }
  },
  {
    path: '/note',
    name: 'note',
    component: Note,
    children:[
      {
        path:"familyview",
        name:"FamilyView",
        component: FamilyView
      },
      {
        path:"avatarview",
        name:"AvatarView",
        component: AvatarView
      }
    ]
  },
  {
    path: '/user',
    name: 'userviewe',
    component: UserView
  },
]

const router = new VueRouter({
  routes,
  // mode:"hash"//默认是hash有锚点（路径中会有#）
  mode:"history"
})

export default router
